- name: Create temporary file
  tempfile: state=file suffix=.yml
  register: tmpfile
  run_once: true

- name: Copy template {{template}} to temporary file ({{tmpfile.path}})
  template: src={{roles_path}}/openshift-apps/{{app}}/templates/{{template}} dest={{tmpfile.path}}
  when: template is defined
  run_once: true

- name: Copy template {{template_fullpath}} to temporary file ({{tmpfile.path}})
  template: src={{template_fullpath}} dest={{tmpfile.path}}
  when: template_fullpath is defined
  run_once: true

- name: Copy file {{file}} to temporary file ({{tmpfile.path}})
  copy: src={{roles_path}}/openshift-apps/{{app}}/files/{{file}} dest={{tmpfile.path}}
  when: file is defined
  run_once: true

- name: Call `oc apply` on the copied file
  shell: oc -n {{app}} apply -f {{tmpfile.path}}
  run_once: true

- name: Delete temporary file
  file: path={{tmpfile.path}} state=absent
  run_once: true
